﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://wpfimageviewer.codeplex.com
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using BrainTechLLC;
using System.Windows.Threading;
using System.Windows;
using BrainTechLLC.ThreadSafeObjects;
using System.Threading;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.Serialization;

namespace BrainTechLLC
{
    [Serializable]
    [DataContract]
    public class BaseTrackModified : BaseNotifyPropertyChanged
    {
        [DataMember]
        public bool _modified;
        [DataMember]
        public bool _attached;

        public BaseTrackModified()
        {
            AttachModifiedTracker();
        }

        protected void AttachModifiedTracker()
        {
            this.PropertyChanged += new PropertyChangedEventHandler(BaseTrackModified_PropertyChanged);
            _attached = true;
        }

        private void BaseTrackModified_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName != "Modified")
            {
                Modified = true;
            }
        }

        public bool Modified
        {
            get { return _modified; }
            set
            {
                if (_modified != value)
                {
                    _modified = value;
                    OnPropertyChanged("Modified");
                }
            }
        }
    }
}
